package angry.courses.entities;
import javax.persistence.*;

@Entity
@Table(name="students")
@NamedQueries({
	@NamedQuery(name="retrieveStudents", query="SELECT s FROM StudentEntity s"),
	@NamedQuery(name="retrieveStudentById", query="SELECT s FROM StudentEntity s WHERE s.sid=:sid"),
	@NamedQuery(name="retrieveStudentByName", query="SELECT s FROM StudentEntity s WHERE s.name=:name"),
	@NamedQuery(name="retrieveStudent", query="SELECT s FROM StudentEntity s WHERE s.reg_no=:regnr")
})
public class StudentEntity implements java.io.Serializable {

	//create table students(sid int NOT NULL AUTO_INCREMENT PRIMARY KEY , name varchar(25), reg_no varchar(10) UNIQUE, year_of_study int);

	@Id
	@GeneratedValue
	@Column(name="sid",nullable=false)
	int sid;

	@Column(name="name",length=25)
	String name;

	@Column(name="reg_no",length=10,unique=true)
	String reg_no;

	@Column(name="year_of_study")
	int year_of_study;

	public StudentEntity() {}	

	public StudentEntity(String name, String reg_no, int year_of_study) {
		this.name = name;
		this.reg_no = reg_no;
		this.year_of_study = year_of_study;
	}

	public String getName() {
		return name;
	}

	public String getRegNo() {
		return reg_no;
	}

	public int getYearOfStudy() {
		return year_of_study;
	}
	
	public void setYearOfStudy(int year) {
		this.year_of_study = year;
	}

	public int getID() {
		return sid;
	}
}
